package com.spring.controller.service.impl;

import com.spring.controller.service.HelloServiceRemote;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author: chenhs
 * @date: Created in 14:45 2019/8/7
 **/
@Service("helloService")
public class HelloServiceRemoteImpl implements HelloServiceRemote {


    @Override
    public void sayHello(String name) {
        new CreateQrcodeThread(name).start();
        System.out.print(new Date());
        System.out.println("可能正在执行asyncRun()....." );
    }

    /**
     * 异步线程执行
     */
    class CreateQrcodeThread extends Thread {
        private String name;

        public CreateQrcodeThread(String name) {
            this.name = name;
        }

        @Override
        public void run() {
            try {
                Thread.sleep(5000);
                System.out.print(new Date());
                System.out.println(name + "正在异步处理asyncRun()方法....");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
